<?php
$a = 10;
$a = 100;
echo $a;

define("PI", 3.1415926);
// PI = 1000; // 不能改变常量的值
echo PI;
echo "<br>";
echo false;

echo "<hr>";
$a = 10;
$s = "abc";
$f = 12.3;
$n = null; // ""
echo $a;
echo "<br>";
echo $s;
echo "<br>";
echo $f;
echo "<br>";
echo $n;
echo "<br>";

echo "<hr>";
echo $s, $f;
echo "<br>";
print "abcd<br>";

$arr = [1,"3",4,true];
// echo $arr;
print_r($arr);

echo "<hr>";

var_dump(true);
var_dump("qqqq");
var_dump($f);
echo "<br>";
var_dump($arr);

echo $f;
echo "<br>";

echo "<hr>";

echo gettype("abc");
echo "<br>";
echo "<hr>";

$m = "123aa";
echo var_dump($m);
echo "<br>";
$n = (int) $m;
echo var_dump($n);
echo "<br>";

var_dump((array)"a");
echo "<br>";

$name = "abc";
var_dump($name);
echo "<br>";
unset($name);// 把该变量的值变为null
// $name = null;
var_dump($name);

echo "<hr>";

$arr = [];
$q = (bool) $arr;
var_dump($q);

echo "<hr>";

echo "12" + "34"; // 12 + 34
echo "<br>";

echo "a12" + "b34"; // 0 + 0
echo "<br>";

echo "12" . "34"; // 字符串拼接
echo "<br>";

var_dump("aaa");
echo "<br>";
var_dump('qqq');
echo '<br>';

$s = 123;
echo "测试： $s <br>"; // 模板字符串
echo '测试： $s <br>';

echo "$s是一个三位数<br>"; // 有问题
// 为了避免上述的问题, 一般建议 把变量写在 {} 中间
echo "{$s}是一个三位数<br>";

$n1 = 5;
$n2 = 2;
var_dump($n1/$n2);

echo "<br>";
var_dump("1" == 1);
echo "<br>";
var_dump("1" === 1);
echo "<br>";

$n3 = 10;
$n3+=20;
echo $n3;
echo "<br>";

$n4 = "ab";
$n4.="qwe";
echo $n4;
echo "<br>";

var_dump(!(1==2));

var_dump( 1==2 && 2==2 );
var_dump( 1==2 || 3==2 );

// 数码宝贝: 蛋 幼年期 成长期 成熟期 完全体 究极体
$body = 10;// 身体数值
if($body >= 60){
    echo "究极体";
} else if($body >= 40) {
    echo "完全体";
} else if($body >= 18) {
    echo "成熟期";
} else if($body >= 6) {
    echo "成长期";
} else if($body >= 1) {
    echo "幼年期";
} else {
    echo "这是一个数码蛋";
}
echo "<br>";
$day = 2;// 星期几
switch($day){
  case "6":
    echo "请假了，正在睡懒觉";
    break;
  case "1":
    echo "要上学，心情不愉快";
    break;
  case "2":
  case "3":
  case "4":
    echo "已经习惯了，没感觉了";
    break;
  case "5":
    echo "明天是周末，有点小激动";
    break;
  default:
    echo "星期天是充满了未知的一天???";
    break;
}

echo "<hr>";

for($i=0; $i<5; $i++){
    echo "<div>i={$i}</div>";
}

echo "<hr>";
$arr = ['a','b','c','d'];
foreach ($arr as $str) {
    echo "<div>{$str}</div>";
}
echo "<hr>";

foreach ($arr as $index => $item) {
    echo "<div>{$index} = {$item}</div>";
}
echo "<hr>";

for($i=0; $i<4; $i++){
    echo "<p>ppp={$i}</p>";
    if($i == 2){
        continue;
    }
    echo "<div>{$arr[$i]}</div>";
}

?>
